package com.hsylient.spring.eneity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.Serializable;

@Component
public class Person implements Serializable {

    @Value("123")
    private Integer id;
    @Value("hsylient")
    private String name;

    public Person() {
        System.out.println("构造方法。。。。。");
    }

    public Person(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }


    public void setId(Integer id) {
        System.out.println("setId()方法被调用。。。。");
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        System.out.println("setName()方法被调用。。。。");
        this.name = name;
    }

    @PostConstruct
    public void init() {
        System.out.println("init() .....");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("destroy().....");
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
